const Koa = require('koa');
const Router = require('koa-router');

const server = new Koa();
server.listen(8081);

server.use(async (ctx, next)=>{
  ctx.set('Access-Control-Allow-Origin', '*');
  await next();
});

let r1 = Router();

r1.get('/list', async ctx => {
  ctx.body = [
    {name: '玩具', price: 100, sales: 5000, id: 1},
    {name: '衣服', price: 180, sales: 2000, id: 2},
    {name: '运动鞋', price: 140, sales: 1500, id: 3},
    {name: '皮包', price: 350, sales: 800, id: 4}
  ]
})

server.use(r1.routes());
